package com.yanqu.road.server.cmd.patrons;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.patrons.PatronsProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.patrons.PatronsModule;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = PatronsProto.PatronsContractBeautyReqMsg.class, respMsg = PatronsProto.PatronsContractBeautyRespMsg.class)
@Cmd(code = Protocol.S_PATRONS_CONTRACT_BEAUTY, desc = "门客契约美女")
public class PatronsContractBeautyCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        PatronsProto.PatronsContractBeautyReqMsg reqMsg = PatronsProto.PatronsContractBeautyReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(PatronsModule.class).contractBeauty(reqMsg.getPatronsId(), reqMsg.getPos(), reqMsg.getBeautyId());
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_PATRONS_CONTRACT_BEAUTY, PatronsProto.PatronsContractBeautyRespMsg.newBuilder().setRet(ret));
        }
    }
}
